package com.xxx.http;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

/**
 * @version v1.0
 * @Description:
 * @Author zhanzhongxin
 * @Date 2021/8/4 9:31
 * @Copyright 博为峰
 */
public class RequestDemo01 extends HttpServlet {
    @Override
    protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        final String name = req.getParameter("name");
        System.out.println("name = " + name);
//        final byte[] bytes = name.getBytes("ios-8859-1");
//        final String s = new String(bytes, "utf-8");
//        System.out.println("s = " + s);
    }

    @Override
    protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        req.setCharacterEncoding("utf-8");
        final String name = req.getParameter("name");
        System.out.println("name = " + name);
    }
}
